<template>
  <div class="all">
    <div class="top">
      <header>
        <div class="div" @click="back">
          <img src="../../../../assets/返回.png" alt="">
          <span class="solid">返回</span>
        </div>
        <div class="div">
          <div class="tabLeft tab" :class="tabIndex == 0 ? 'tabSelect' : ''" @click="clickTabs(0)">已分配</div>
          <div class="tabRight tab" :class="tabIndex == 1 ? 'tabSelect' : ''" @click="clickTabs(1)">未分配</div>
        </div>
        <div class="div">
          <span></span>
        </div>
      </header>
      <div class="menu" v-show="tabIndex == 0">
        <van-search
          v-model="yi.searchValue"
          shape="round"
          placeholder="患者姓名/所属组/档案管理医生"
          left-icon=""
          show-action
          @keyup="onSearch1"
          @clear="onSearch1"
        >
          <template #left-icon>
            <div @click="onSearch1">
              <van-icon name="search" />
            </div>
          </template>
          <template #action>
          </template>
        </van-search>
        <van-dropdown-menu style="" active-color="#1da4f2" >
          <van-dropdown-item  :title="yi.value1" ref="items" >
            <ul class="cityUl">
               <li class="cityLi">
                 <p :class="item.text == yi.province ? 'selectProvince' : ''"
                    v-for="(item, index) in itemsCity" :key="index" @click="clickProvince(item, index)">
                   <a >{{item.text}}</a>
<!--                   <img v-show="item.text == yi.province" src="../../assets/选择蓝@2x.png"-->
<!--                        class="selectImg" alt="">-->
                 </p>
               </li>
                <li class="cityLi">
                  <p v-for="(curr, currIndex) in itemsCity[yi.provinceIndex].children" :key="currIndex"
                     @click="clickCity(curr, currIndex)">
                    <a >{{curr.text}}</a>
                    <img v-show="curr.text == yi.city" src="../../../../assets/selectImg/选择蓝@2x.png"
                         class="selectImg" alt="">
                  </p>
                </li>
              </ul>
            <div class="popBottom">
              <button @click="reset()">重置</button>
              <button @click="affirm()">确认</button>
            </div>
          </van-dropdown-item>

          <van-dropdown-item :title="yi.value2"  ref="Zuitem">
            <van-collapse v-model="activeNames">
              <div v-for="(curr, index) in erjiList"
                   :key="index"
                   @click="clickErji(curr, 1)"
              >
                <van-collapse-item
                  v-if="erjiList"
                  :name="curr.id"
                >
                  <template #title>
                    <div class="tempTitle"  @click="clickErji(curr, 1)">
                    <span>
                     <img v-if="yi.selectID == curr.id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                      <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                        {{curr.group_name}}
                    </span>
                      <img src="../../../../assets/selectImg/选择蓝@2x.png" v-show="yi.selectID == curr.id" class="selectImg" alt="">
                    </div>
                  </template>
<!--                  <p class="PTree" v-if="curr.members"-->
<!--                     v-for="(item, itemIndex) in curr.members"-->
<!--                     :key="itemIndex"-->
<!--                     @click="selectTree(item, 1, curr)"-->
<!--                  >-->
<!--                  <span>-->
<!--                     <img v-if="yi.doc_user_id == item.selectID" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">-->
<!--                      <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">-->
<!--                      <img v-if="item.PHOTO" :src="item.PHOTO" alt="" class="photo">-->
<!--                      <img v-else src="../../../../assets/photo.png" alt="" class="photo">-->
<!--                      {{item.NICK_NAME}}-->
<!--                  </span>-->
<!--                    <img src="../../../../assets/选择蓝@2x.png" v-show="yi.selectID == item.doc_user_id" class="selectImg" alt="">-->
<!--                  </p>-->

                  <!--嵌套折叠开始-->
                  <van-collapse v-model="activeNamesChilden" v-if="curr.xiaji">
                    <van-collapse-item
                      v-for="(currXiaji, xiajiIndex) in curr.xiaji"
                      :key="xiajiIndex"
                      :name="currXiaji.id"
                    >
                      <template #title>
                        <div class="tempTitle"   @click="clickErji(currXiaji, 1)">
                        <span>
                            <img v-if="yi.selectID == currXiaji.id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                            <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                          {{currXiaji.group_name}}
                        </span>
                          <img src="../../../../assets/selectImg/选择蓝@2x.png" v-show="yi.selectID == currXiaji.id" class="selectImg" alt="">
                        </div>
                      </template>
                      <p class="PTree"
                         v-for="(item, itemIndex) in currXiaji.members"
                         :key="itemIndex"
                         @click="selectTree(item, 1, currXiaji)"
                      >
                      <span>
                        <img v-if="yi.selectID == item.doc_user_id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                        <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                        <img v-if="item.PHOTO" :src="item.PHOTO" class="photo" alt="">
                        <img v-else src="../../../../assets/photo.png" alt="" class="photo">
                        {{item.NICK_NAME}}
                      </span>
                        <img src="../../../../assets/selectImg/选择蓝@2x.png" v-show="yi.selectID == item.doc_user_id" class="selectImg" alt="">
                      </p>

                    </van-collapse-item>
                  </van-collapse>
                  <!--嵌套折叠结束-->

                </van-collapse-item>
              </div>
            </van-collapse>
            <div class="popBottom">
              <button @click="zuReset()">重置</button>
              <button @click="zuComfrim()">确认</button>
            </div>
          </van-dropdown-item>
        </van-dropdown-menu>
      </div>
      <div class="menu menu1" style="display: flex;" v-show="tabIndex == 1">
        <van-dropdown-menu style="" active-color="#1da4f2" >
          <van-dropdown-item  :title="yi.value1" ref="item" >
            <ul class="cityUl">
              <li class="cityLi">
                <p :class="item.text == yi.province ? 'selectProvince' : ''"  v-for="(item, index) in itemsCity" :key="index" @click="clickProvince(item, index)">
                  <a >{{item.text}}</a>
<!--                  <img v-show="item.text == yi.province" src="../../assets/选择蓝@2x.png"-->
<!--                       class="selectImg" alt="">-->
                </p>
              </li>
              <li class="cityLi">
                <p v-for="(curr, currIndex) in itemsCity[yi.provinceIndex].children" :key="currIndex"
                   @click="clickCity(curr, currIndex)">
                  <a >{{curr.text}}</a>
                  <img v-show="curr.text == yi.city" src="../../../../assets/selectImg/选择蓝@2x.png"
                       class="selectImg" alt="">
                </p>
              </li>
<!--              <li  class="cityLi" >-->
<!--                <p v-for="(curr, currIndex) in itemsCity[yi.provinceIndex].children[yi.cityIndex].children" :key="currIndex"-->
<!--                   @click="clickArea(curr, currIndex)"-->
<!--                >-->
<!--                  <a >{{curr.text}}</a>-->
<!--                  <img v-show="curr.text == yi.area" src="../../assets/选择蓝@2x.png"-->
<!--                       class="selectImg" alt="">-->
<!--                </p>-->
<!--              </li>-->
            </ul>
            <div class="popBottom">
              <button @click="reset()">重置</button>
              <button @click="affirm()">确认</button>
            </div>
          </van-dropdown-item>
        </van-dropdown-menu>
        <van-search
          style="width: 75%;"
          v-model="wei.searchValue"
          shape="round"
          placeholder="患者姓名"
          left-icon=""
          show-action
          @keyup="onSearch1"
          @clear="onSearch1"
        >
          <template #left-icon>
            <div @click="onSearch1">
              <van-icon name="search" />
            </div>
          </template>
          <template #action>
          </template>
        </van-search>
      </div>
    </div>
    <div class="box" v-for="(item, index) in fileList" @click="clickFile(item)" :key="index">
      <p class="pHeader">
        <span>
          <img v-if="item.PHOTO" class="photo" :src="item.PHOTO" alt="">
          <img v-else src="../../../../assets/photo.png" alt="" class="photo">
          <a class="fontWeightBlod">{{item.tuomin_name}}</a>
          <a >{{item.SEX == 1 ? '男' : '女'}}</a>
          <a >{{item.age}}岁</a>
        </span>
        <span>
          <a class="tag updateTag" v-if="tabIndex == 0  && item.staff_name" @click.stop="clickFenpei(item)">更改分配</a>
          <a class="tag keepTag" v-else-if="tabIndex == 0" @click.stop="clickFenpei(item)">调整分配</a>
          <a class="tag updateTag" v-show="tabIndex == 1" @click.stop="clickFenpei(item)">分配</a>
        </span>
      </p>
      <p>联系电话：{{item.tuomin_phone}}</p>
      <p style="white-space: nowrap;text-overflow: ellipsis;overflow: hidden">家庭地址：{{item.tuomin_address}}</p>
      <p  v-show="tabIndex == 0" >档案管理: {{item.docinfo}}</p>
<!--      <p   v-show="tabIndex == 0" style="margin-top: 8px;">-->
<!--        <a >所属组：</a>-->
<!--        <a style="width: 80%;-->
<!--        overflow: hidden;-->
<!--        white-space: nowrap;-->
<!--text-overflow: ellipsis">-->
<!--          {{GroupName(item.docs, 'group') }}-->
<!--        </a>-->
<!--      </p>-->
<!--      <p v-show="tabIndex == 0" >-->
<!--        <a style="white-space: nowrap">档案管理医生：</a>-->
<!--        <a style="width: 70%;-->
<!--        overflow: hidden;-->
<!--        white-space: nowrap;-->
<!--text-overflow: ellipsis">{{GroupName(item.docs, 'doctor')}}</a>-->
<!--&lt;!&ndash;        <a v-else style="color: #999999"> (未指定)</a>&ndash;&gt;-->
<!--      </p>-->
    </div>
    <van-empty
      style="width: 100%;height: 60%"
      v-show="fileList.length <= 0 && isLoading === false"
      class="custom-image"
      :image="require('../../../../assets/空两本书.png')"
      :description="description"
    />
    <div  style="width: 100%;height: 50vh;display: flex;align-items: center;justify-content: center" v-show="isLoading">
      <van-loading size="24px" type="spinner" color="#1989fa">加载中...</van-loading>
    </div>
    <van-popup v-model="show"
               @close="closePop()"
               round position="bottom" :style="{ height: '100%', bottom: '50px' }" >
      <div class="popHeader">
          <div class="div" style="color: #999999"
               @click="show = false, group_id = '', doc_user_id = '',selectID = '', activeNames = []
              activeNamesChilden = []"
          >取消</div>
          <div class="div">
            <ul style="display: flex">
              <li
                @click="popTabIndex = 0"
                :class="popTabIndex == 0 ? 'popSelect' : ''"
                style="padding: 5px 0;box-sizing: border-box">管理医生分配</li>
              <li
                @click="popTabIndex = 1"
                :class="popTabIndex == 1 ? 'popSelect' : ''"
                style="margin-left: 10px;padding: 5px 0;box-sizing: border-box">查看医生分配</li>
            </ul>
          </div>
          <div class="div"></div>
          <!--        <div class="div solid" @click="feiPeiConfirm()">确认</div>-->
        </div>
      <van-collapse v-model="PoPactiveNames">
        <van-collapse-item
          v-if="erjiList"
          v-for="(curr, index) in erjiList"
          :key="index"
          :name="curr.id"
        >
          <template #title>
            <div class="tempTitle"  @click="clickErji(curr, 2)">
              <span>
                <img v-if="selectID == curr.id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                 {{curr.group_name}}
              </span>
              <img src="../../../../assets/selectImg/选择蓝@2x.png" v-show="selectID == curr.id" class="selectImg" alt="">
            </div>
          </template>
          <p class="PTree"
             v-if="curr.members" v-for="(item, itemIndex) in curr.members"
             :key="itemIndex"
             @click="selectTree(item, 2, curr)"
          >
            <span>
              <img v-if="selectID == item.doc_user_id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
              <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
              <img v-if="item.PHOTO" :src="item.PHOTO" alt="" class="photo">
              <img v-else src="../../../../assets/photo.png" alt="" class="photo">
              {{item.NICK_NAME}}
            </span>
            <img src="../../../../assets/selectImg/选择蓝@2x.png" v-show="selectID == item.doc_user_id" class="selectImg" alt="">
          </p>

          <!--嵌套折叠开始-->
          <van-collapse v-model="PoPactiveNamesChilden" v-if="curr.xiaji">
            <van-collapse-item
              v-for="(currXiaji, xiajiIndex) in curr.xiaji"
              :key="xiajiIndex"
              :name="currXiaji.id"
            >
              <template #title>
                <div class="tempTitle"  @click="clickErji(currXiaji, 2)">
                   <span>
                    <img v-if="selectID == currXiaji.id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                    <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                     {{currXiaji.group_name}}
                    </span>
                  <img src="../../../../assets/selectImg/选择蓝@2x.png" v-show="selectID == currXiaji.id" class="selectImg" alt="">
                </div>
              </template>
              <p class="PTree"
                 v-for="(item, itemIndex) in currXiaji.members"
                 :key="itemIndex"
                 @click="selectTree(item, 2, currXiaji)"
              >
                <span>
                  <img v-if="selectID == item.doc_user_id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                  <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                  <img v-if="item.PHOTO" :src="item.PHOTO" class="photo" alt="">
                  <img v-else src="../../../../assets/photo.png" alt="" class="photo">
                  {{item.NICK_NAME}}
                </span>
                <img src="../../../../assets/selectImg/选择蓝@2x.png" v-show="selectID == item.doc_user_id" class="selectImg" alt="">
              </p>

            </van-collapse-item>
          </van-collapse>
          <!--嵌套折叠结束-->

        </van-collapse-item>
      </van-collapse>
    </van-popup>
<!--    <van-popup v-model="show"
               @close="closePop()"
               round position="bottom" :style="{ height: '80%', bottom: '50px' }" >
      <div class="popHeader">
        <div class="div" style="color: #999999"
             @click="show = false, group_id = '', doc_user_id = '',selectID = '', activeNames = []
              activeNamesChilden = []"
        >取消</div>
        <div class="div">
          <ul style="display: flex">
            <li
              @click="popTabIndex = 0"
              :class="popTabIndex == 0 ? 'popSelect' : ''"
                style="padding: 5px 0;box-sizing: border-box">管理医生分配</li>
            <li
              @click="popTabIndex = 1"
              :class="popTabIndex == 1 ? 'popSelect' : ''"
                style="margin-left: 10px;padding: 5px 0;box-sizing: border-box">查看医生分配</li>
          </ul>
        </div>
        <div class="div"></div>
&lt;!&ndash;        <div class="div solid" @click="feiPeiConfirm()">确认</div>&ndash;&gt;
      </div>
      <van-collapse v-model="PoPactiveNames">
        <van-collapse-item
          v-if="erjiList"
          v-for="(curr, index) in erjiList"
          :key="index"
          :name="curr.id"
        >
          <template #title>
            <div class="tempTitle"  @click="clickErji(curr, 2)">
              <span>
                <img v-if="selectID == curr.id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                 {{curr.group_name}}
              </span>
              <img src="../../../../assets/选择蓝@2x.png" v-show="selectID == curr.id" class="selectImg" alt="">
            </div>
          </template>
          <p class="PTree"
             v-if="curr.members" v-for="(item, itemIndex) in curr.members"
             :key="itemIndex"
             @click="selectTree(item, 2, curr)"
          >
            <span>
              <img v-if="selectID == item.doc_user_id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
              <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
              <img v-if="item.PHOTO" :src="item.PHOTO" alt="" class="photo">
              <img v-else src="../../../../assets/photo.png" alt="" class="photo">
              {{item.NICK_NAME}}
            </span>
              <img src="../../../../assets/选择蓝@2x.png" v-show="selectID == item.doc_user_id" class="selectImg" alt="">
          </p>

          &lt;!&ndash;嵌套折叠开始&ndash;&gt;
          <van-collapse v-model="PoPactiveNamesChilden" v-if="curr.xiaji">
            <van-collapse-item
              v-for="(currXiaji, xiajiIndex) in curr.xiaji"
              :key="xiajiIndex"
              :name="currXiaji.id"
            >
              <template #title>
                <div class="tempTitle"  @click="clickErji(currXiaji, 2)">
                   <span>
                    <img v-if="selectID == currXiaji.id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                    <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                     {{currXiaji.group_name}}
                    </span>
                  <img src="../../../../assets/选择蓝@2x.png" v-show="selectID == currXiaji.id" class="selectImg" alt="">
                </div>
              </template>
              <p class="PTree"
                 v-for="(item, itemIndex) in currXiaji.members"
                 :key="itemIndex"
                 @click="selectTree(item, 2, currXiaji)"
              >
                <span>
                  <img v-if="selectID == item.doc_user_id" class="treeImg" src="../../../../assets/选中树状蓝.png" alt="">
                  <img v-else src="../../../../assets/未选中树状灰.png" class="treeImg" alt="">
                  <img v-if="item.PHOTO" :src="item.PHOTO" class="photo" alt="">
                  <img v-else src="../../../../assets/photo.png" alt="" class="photo">
                  {{item.NICK_NAME}}
                </span>
                <img src="../../../../assets/选择蓝@2x.png" v-show="selectID == item.doc_user_id" class="selectImg" alt="">
              </p>

            </van-collapse-item>
          </van-collapse>
          &lt;!&ndash;嵌套折叠结束&ndash;&gt;

        </van-collapse-item>
      </van-collapse>
    </van-popup>-->
    <van-dialog v-model="fenpeiShow"
                width="80%"
                confirm-button-color="#1da4f2"
                :title="`确认将档案分配给`+selectName+`吗？`"
                @confirm="Confirm()"
                show-cancel-button>
    </van-dialog>
  </div>
</template>

<script>
import {Toast} from 'vant'
import TreeSelectCity from '../../../../components/China/TreeSelectCity'
export default {
  name: 'FileDistributionList',
  data () {
    return {
      itemsCity: TreeSelectCity.children,
      tabIndex: 0,
      // 已分配筛选
      yi: {
        provinceIndex: 0,
        cityIndex: 0,
        province: '全国',
        city: '全国',
        area: '全国',
        value1: '全国',
        value2: '组/医生',
        searchValue: '',
        group_id: '',
        doc_user_id: '',
        selectID: ''
      },
      // 未分配筛选
      wei: {
        searchValue: ''
      },
      isLoading: true,
      team_id: this.$route.query.team_id,
      // 下拉菜单 分配医生展示
      activeNames: [],
      activeNamesChilden: [],
      fileList: [],
      // 弹出框 分配医生展示
      show: false,
      PoPactiveNames: [],
      PoPactiveNamesChilden: [],
      erjiList: [],
      selectID: '',
      selectName: '',
      group_id: '', // 团队小组ID
      doc_user_id: '', // 管理档案医生ID
      fenpeiShow: false,
      ITEM: [],
      popTabIndex: 0
    }
  },
  computed: {
    GroupName () {
      return function (list, lei) {
        let name = ''
        if (list) {
          if (lei == 'doctor') {
            list.map((curr, index) => {
              if (curr.NICK_NAME) {
                name += curr.NICK_NAME + '、'
              }
            })
          } else if (lei == 'group') {
            let opNameArr = []
            list.map((curr, index) => {
              if (curr.group_name) {
                opNameArr.push(curr.group_name)
              }
            })
            opNameArr = new Set(opNameArr)
            opNameArr = Array.from(opNameArr)
            opNameArr.map((curr, index) => {
              name += curr + '、'
            })
          }
        } else {
          if (lei == 'doctor') {
            name = '(未指定)、'
          }
        }
        return name.substring(0, name.length - 1)
      }
    },
    description () {
      if (this.tabIndex == 0) {
        return '暂无已分配档案'
      } else {
        return '暂无未分配档案'
      }
    }
  },
  mounted () {
    this.clickTabs(0)
    this.getTeamErji()
  },
  methods: {
    clickFile (item) {
      if (this.tabIndex == 0) {
        this.$router.push({path: '/filesXiang',
          query: {
            userid: item.data_user_id,
            team_id: this.team_id
          }})
      }
    },
    // 关闭弹窗
    closePop () {
      this.group_id = ''
      this.doc_user_id = ''
      this.selectID = ''
      this.PoPactiveNames = []
      this.PoPactiveNamesChilden = []
    },
    // 点击 分配按钮
    clickFenpei (item) {
      let patient_type = ''
      if (item.patient_type) {
        patient_type = item.patient_type
      } else if (this.tabIndex === 0) {
        patient_type = '1'
      }
      this.$router.push({path: '/PeopleFenpei', query: {userid: this.userid, team_id: this.team_id, data_user_id: item.data_user_id,patient_type: patient_type}})
    },
    // 分配确认
    Confirm () {
      let jth_id
      let doc_user_id
      if (this.doc_user_id && this.doc_user_id !== '') {
        doc_user_id = this.doc_user_id
      }
      if (this.tabIndex == 0) {
        jth_id = this.ITEM.jth_id
        this.$http.updateTeamHealth({
          team_id: this.team_id, // 团队id
          data_user_id: this.ITEM.data_user_id, // 档案人userid
          group_id: this.group_id, // 团队小组ID
          doc_user_id: doc_user_id, // 管理档案医生ID
          jth_id: jth_id // 新增时传0，继续分配和修改时传对应的值
        })
          .then(res => {
            console.log(res)
            if (res.data.status === 'success') {
              Toast('分配成功')
              this.clickTabs(this.tabIndex)
              this.show = false
              this.activeNames = []
              this.activeNamesChilden = []
            } else {
              Toast(res.data.msg)
            }
          })
          .catch(err => {
            console.log(err)
            Toast('您的网络有些拥挤，请稍后再试')
          })
      } else {
        this.$http.saveTeamHealth({
          team_id: this.team_id, // 团队id
          data_user_id: this.ITEM.data_user_id, // 档案人userid
          group_id: this.group_id, // 团队小组ID
          doc_user_id: doc_user_id, // 管理档案医生ID
          jth_id: jth_id
        })
          .then(res => {
            console.log(res)
            if (res.data.status === 'success') {
              Toast('分配成功')
              this.clickTabs(this.tabIndex)
              this.show = false
              this.activeNames = []
              this.activeNamesChilden = []
            } else {
              Toast(res.data.msg)
            }
          })
          .catch(err => {
            console.log(err)
            Toast('您的网络有些拥挤，请稍后再试')
          })
      }
    },
    // 确认分配
    feiPeiConfirm () {
      if (this.selectID) {
        this.fenpeiShow = true
      }
    },
    // 已分配列表
    getYiData () {
      this.fileList = []
      this.isLoading = true
      let NowCity
      if (this.yi.value1 === '全国') {
        NowCity = ''
      } else {
        NowCity = this.yi.value1
      }
      this.$http.findTeamHealthYi({team_id: this.team_id, group_id: this.yi.group_id, city: NowCity, name: this.yi.searchValue})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            this.fileList = res.data.data
            this.isLoading = false
          } else {
            this.isLoading = false
            Toast(res.data.msg)
          }
        })
        .catch(err => {
          console.log(err)
          Toast('您的网络有些拥挤，请稍后再试')
        })
    },
    // 未分配列表
    getWeiData () {
      this.fileList = []
      this.isLoading = true
      let NowCity
      if (this.yi.value1 === '全国') {
        NowCity = ''
      } else {
        NowCity = this.yi.value1
      }
      this.$http.findTeamHealthWei({team_id: this.team_id, city: NowCity, name: this.wei.searchValue})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            this.isLoading = false
            this.fileList = res.data.data
          } else {
            this.isLoading = false
            Toast(res.data.msg)
          }
        })
        .catch(err => {
          console.log(err)
          Toast('您的网络有些拥挤，请稍后再试')
        })
    },
    // 获取二级列表
    getTeamErji () {
      this.$http.findTeamGroupTwo({team_id: this.team_id})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            this.erjiList = res.data.data
          } else {
            Toast(res.data.msg)
          }
        })
        .catch(err => {
          console.log(err)
          Toast('您的网络有些拥挤，请稍后再试')
        })
    },
    // 二级列表点击下的成员信息或二级列表
    clickErji (item, num) {
      this.$http.findTeamGroupTwoAndThree({id: item.id})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            let Data = res.data.data
            this.$set(item, 'xiaji', Data.xiaji)
            this.$set(item, 'members', Data.members)
          } else {
            Toast(res.data.msg)
          }
        })
        .catch(err => {
          console.log(err)
          Toast('您的网络有些拥挤，请稍后再试')
        })
      if (num == 1) {
        this.yi.group_id = item.id
        this.yi.selectID = item.id
        this.yi.doc_user_id = ''
        this.activeNamesChilden = []
      } if (num == 2) {
        this.group_id = item.id
        this.doc_user_id = ''
        this.selectID = item.id
        this.selectName = item.group_name
        this.PoPactiveNamesChilden = []
      }
    },
    // 选中 树状图的某一个 医生
    selectTree (item, num, curr) {
      console.log(curr)
      if (num == 1) {
        this.yi.group_id = curr.id
        this.yi.doc_user_id = item.doc_user_id
        this.yi.selectID = item.doc_user_id
      } else {
        this.group_id = curr.id
        this.doc_user_id = item.doc_user_id
        this.selectID = item.doc_user_id
        this.selectName = item.NICK_NAME
      }
    },
    // 组筛选 重置
    zuReset () {
      this.yi.group_id = ''
      this.yi.doc_user_id = ''
      this.clickTabs(this.tabIndex)
    },
    // 组筛选 确认
    zuComfrim () {
      this.clickTabs(this.tabIndex)
      this.$refs.Zuitem.toggle()
    },
    // 返回
    back () {
      this.$router.history.go(-1)
    },
    // 已分配搜索
    onSearch1 () {
      this.clickTabs(this.tabIndex)
    },
    // 头部标签切换
    clickTabs (num) {
      this.tabIndex = num
      if (num == 0) {
        this.getYiData()
      } else if (num == 1) {
        this.getWeiData()
      }
    },
    // 省
    clickProvince (item, index) {
      this.yi.province = item.text
      this.yi.provinceIndex = index

      this.yi.cityIndex = 0
      this.yi.city = item.children[0].text
      this.yi.area = item.children[0].children[0].text
    },
    // 市
    clickCity (item, index) {
      this.yi.city = item.text
      this.yi.cityIndex = index
    },
    // 区
    clickArea (item, index) {
      this.yi.area = item.text
    },
    reset () {
      let item = this.itemsCity[0]
      this.yi.province = item.text
      this.yi.provinceIndex = 0

      this.yi.cityIndex = 0
      this.yi.city = item.children[0].text
      this.yi.area = item.children[0].children[0].text
      this.$refs.item.toggle()
      this.$refs.items.toggle()
      this.clickTabs(this.tabIndex)
    },
    affirm () {
      this.yi.value1 = this.yi.city
      this.$refs.item.toggle()
      this.$refs.items.toggle()
      this.clickTabs(this.tabIndex)
    }
  }
}
</script>

<style scoped>
  .all{
    width: 100%;
    height: 100%;
    background: #FAF9FE;
    overflow: auto;
    font-size: 15px;
    font-family: PingFang SC;
  }
  .top{
    position: sticky;
    top: 0;
    z-index: 9;
  }
  .popHeader,
  header{
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #E5E5E5;
    background: white;

  }
  .div{
    /*width: 33%;*/
    /*flex: 1;*/
    height: 100%;
    display: flex;
    align-items: center;
    font-family: "PingFang SC";
    font-size: 15px;
    font-weight: bold;
  }
  .div img{
    margin-right: 5px;
  }
  .div:nth-child(1) img{
    height: 13px;
    width: 7px;
    margin-left: 15px;
  }
  .div:nth-child(3) img{
    margin-right: 5px;
    width: 13px;
    height: 13px;
  }
  .div:nth-child(3) span{
    margin-right: 15px;
  }
  .div:nth-child(2){
    justify-content: center;
    flex: 3;
  }
  .div:nth-child(1),
  .div:nth-child(3){
    flex: 1;
  }
  .div:nth-child(3){
    justify-content: flex-end;
  }
  .solid{
    color: #1DA4F2;
  }
  .menu{
    background: #FFFFFF;
  }
  .tab{
    width: 75px;
    height: 29px;
    background: #FFFFFF;
    border: 1px solid #1DA4F2;
    margin-right: -1px;
    color: #1da4f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
  }
  .tabSelect{
    color: #FFFFFF !important;
    background: #1da4f2 !important;
  }
  .tabLeft{
    border-radius: 5px 0 0 5px;
  }
  .tabRight{
    border-radius: 0 5px  5px 0 ;
  }

  .cityUl{
    display: flex;
    flex-direction: row;
    overflow: hidden;
  }
  .cityLi{
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
    height: 90vw;
  }
  .cityLi:first-child{
    background: #FAF9FE;
  }
  .cityLi:last-child p {
    border-bottom: 1px solid #e5e5e5;
  }
  .cityLi p{
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 10px;
    padding-right: 10px;
    box-sizing: border-box;
  }
  .cityLi p a{
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .popBottom{
    height: 60px;
    display: flex;
    padding: 0 30px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #E5E5E5;
    position: sticky;
    bottom: 0;
    background: #FFFFFF;
  }
  .popBottom button{
    width: 50%;
    height: 29px;
    border-radius: 5px;
    border: none;
    margin-right: 10px;
  }
  .popBottom button:first-child{
    background: #FFFFFF;
    color: #1da4f2;
    border: 1px solid #1da4f2;
  }
  .popBottom button:last-child{
    background: #1da4f2;
    color: #fff;
  }
  /deep/ .van-dropdown-menu__title::after {
    border-color: transparent transparent #333 #333;
  }
  .box{
    width: 92%;
    margin: 0 auto;
    background: #FFFFFF;
    border-radius: 10px;
    margin-top: 10px;
    padding: 10px;
    box-sizing: border-box;
  }
  .box p{
    min-height: 25px;
    display: flex;
    align-items: center;
    font-size: 13px;
  }
  .box:last-child{
    margin-bottom: 50px;
  }
  .pHeader{
    justify-content: space-between;
    font-size: 15px!important;
  }
  .pHeader span{
    display: flex;
    align-items: center;
  }
  .pHeader span a{
    margin-left: 8px;
  }
  .fontWeightBlod{
    font-weight: bold;
  }
  .photo{
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
  }
  .tag {
    padding: 0 10px;
    box-sizing: border-box;
    height: 22px;
    border: 1px solid #1DA4F2;
    border-radius: 3px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .keepTag {
    color: #1da4f2;
    background: #FFFFFF;
  }
  .updateTag {
    color: #FFFFFF;
    background: #1da4f2;
  }
  /deep/ .van-dropdown-menu__bar{
    box-shadow: none;
    height: 100%;
    min-height: 44px;
  }
  .menu1{
    display: flex;
  }
  .menu1 /deep/ .van-dropdown-menu__item{
    /*flex: none;*/
  }
  .treeImg{
    width: 8px;
    height: 8px;
    margin-right: 8px;
  }
  .tempTitle,
  .PTree{
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #333333;
  }
  .PTree {
    height: 44px;
    padding-left: 15px;
    box-sizing: border-box;
  }
  .tempTitle span,
  .PTree span{
    display: flex;
    align-items: center;
  }
  .PTree .photo{
    margin-right: 8px;
  }
  /deep/ .van-collapse-item__content {
    padding: 0px 16px;
  }
  .popHeader{
    padding: 0 10px;
    box-sizing: border-box;
    position: sticky;
    top:0;
  }
  .selectImg{
    width: 11px;
    height: 7px;
  }
  /deep/ .van-dialog__header--isolated {
    padding: 24px 10px;
  }
  .selectProvince{
    background: #FFFFFF !important;
    box-shadow: 0px 1px 0px 0px #E5E5E5, 0px -1px 0px 0px #E5E5E5;
  }
  .popSelect{
    border-bottom: 2px solid #1da4f2;
    color: #1da4f2;
  }
</style>
